<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI角色黑洞宇宙</title>
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700&family=Roboto:wght@300;400;500&display=swap');
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            background-color: #050505;
            color: #fff;
            font-family: 'Roboto', sans-serif;
            overflow-x: hidden;
            height: 100vh;
            position: relative;
        }
        /* 背景星空效果 */
        body::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: radial-gradient(ellipse at center, #0a0a0a 0%, #000000 70%);
            z-index: -2;
        }
        .star {
            position: absolute;
            background-color: #fff;
            border-radius: 50%;
            animation: twinkle 3s infinite ease-in-out;
            z-index: -1;
        }
        @keyframes twinkle {
            0%, 100% { opacity: 0.2; }
            50% { opacity: 1; }
        }
        /* 主容器 */
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 2rem;
            position: relative;
            z-index: 10;
            height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }
        header {
            text-align: center;
            margin-bottom: 3rem;
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        /* 侧边栏按钮 */
        .sidebar-toggle {
            position: absolute;
            left: 0;
            background: none;
            border: none;
            color: white;
            font-size: 1.5rem;
            cursor: pointer;
            padding: 0.5rem;
            z-index: 20;
        }
        /* 个人按钮 */
        .user-menu {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 1000;
        }
        .user-btn {
            display: flex;
            align-items: center;
            background: rgba(30, 30, 30, 0.8);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            color: #fff;
            padding: 0.5rem 1rem;
            cursor: pointer;
            font-family: 'Roboto', sans-serif;
            transition: all 0.3s ease;
        }
        .user-btn:hover {
            background: rgba(102, 126, 234, 0.2);
            border-color: #667eea;
        }
        .user-icon {
            margin-right: 0.5rem;
            font-size: 1.2rem;
        }
        /* 下拉菜单 */
        .user-dropdown {
            position: absolute;
            top: 100%;
            right: 0;
            background: rgba(25, 25, 25, 0.95);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
            width: 250px;
            z-index: 100;
            display: none;
        }
        /* 个人资料弹窗 */
        .profile-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            z-index: 2000;
            justify-content: center;
            align-items: center;
        }
        .modal-content {
            background: rgba(30, 30, 30, 0.95);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 12px;
            width: 90%;
            max-width: 500px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
        }
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 1.5rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }
        .modal-header h2 {
            margin: 0;
            font-size: 1.5rem;
            color: #fff;
        }
        .close-btn {
            font-size: 2rem;
            color: #aaa;
            cursor: pointer;
            transition: color 0.3s ease;
        }
        .close-btn:hover {
            color: #fff;
        }
        .modal-body {
            padding: 1.5rem;
        }
        .form-group {
            margin-bottom: 1.5rem;
        }
        .form-group label {
            display: block;
            margin-bottom: 0.5rem;
            color: #ddd;
            font-weight: 500;
        }
        .form-control {
            width: 100%;
            padding: 0.8rem;
            background: rgba(20, 20, 20, 0.8);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 6px;
            color: #fff;
            font-family: 'Roboto', sans-serif;
            font-size: 1rem;
            outline: none;
            transition: all 0.3s ease;
        }
        .form-control:focus {
            border-color: #667eea;
            box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
        }
        .modal-footer {
            display: flex;
            justify-content: flex-end;
            gap: 1rem;
            padding: 1.5rem;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }
        .btn {
            padding: 0.7rem 1.5rem;
            border: none;
            border-radius: 6px;
            font-family: 'Roboto', sans-serif;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        .btn-secondary {
            background: rgba(100, 100, 100, 0.3);
            color: #ddd;
        }
        .btn-secondary:hover {
            background: rgba(100, 100, 100, 0.5);
        }
        .btn-primary {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            color: white;
        }
        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
        }
        .user-dropdown.show {
            display: block;
        }
        .dropdown-header {
            display: flex;
            align-items: center;
            padding: 1rem;
        }
        .dropdown-header .user-icon {
            font-size: 2rem;
            margin-right: 1rem;
        }
        .dropdown-username {
            font-weight: 500;
            color: #fff;
            margin-bottom: 0.2rem;
        }
        .dropdown-email {
            font-size: 0.8rem;
            color: #aaa;
        }
        .dropdown-divider {
            height: 1px;
            background: rgba(255, 255, 255, 0.1);
            margin: 0.5rem 0;
        }
        .dropdown-item {
            display: block;
            padding: 0.8rem 1rem;
            color: #ddd;
            text-decoration: none;
            font-size: 0.9rem;
            transition: all 0.2s ease;
        }
        .dropdown-item:hover {
            background: rgba(102, 126, 234, 0.2);
            color: #fff;
        }
        h1 {
            font-family: 'Orbitron', sans-serif;
            font-size: 2.8rem;
            font-weight: 700;
            letter-spacing: 3px;
            margin-bottom: 1rem;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            text-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
        }
        .subtitle {
            font-size: 1.1rem;
            color: #aaa;
            max-width: 600px;
            margin: 0 auto;
            line-height: 1.6;
        }
        /* 搜索区域 */
        .search-section {
            background: rgba(15, 15, 15, 0.7);
            backdrop-filter: blur(10px);
            border-radius: 16px;
            padding: 2.5rem;
            margin-bottom: 3rem;
            border: 1px solid rgba(255, 255, 255, 0.1);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        }
        .search-container {
            display: flex;
            gap: 1rem;
            margin-bottom: 2rem;
        }
        .search-input {
            flex: 1;
            padding: 1rem 1.5rem;
            background: rgba(30, 30, 30, 0.8);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            color: #fff;
            font-size: 1rem;
            font-family: 'Roboto', sans-serif;
            outline: none;
            transition: all 0.3s ease;
        }
        .search-input:focus {
            border-color: #667eea;
            box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
        }
        .search-btn {
            padding: 0 2rem;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 8px;
            font-family: 'Orbitron', sans-serif;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        .search-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
        }
        /* 角色容器 - 使用flex布局并居中 */
        .characters-container {
            position: relative;
            width: 100%;
            flex: 1;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 4rem; /* 增大间距 */
            margin-top: 2rem;
        }
        /* 角色包装器 */
        .character-wrapper {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
            transition: all 0.3s ease;
            cursor: pointer;
        }
        .character-wrapper:hover {
            z-index: 100;
            transform: scale(1.05);
        }
        .character-blackhole {
            position: relative;
            width: 300px;
            height: 300px;
            margin: 0 auto;
            transition: all 0.3s ease;
        }
        .blackhole-core {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 120px;
            height: 120px;
            background: radial-gradient(circle, #0a0a0a 0%, #000000 60%, transparent 100%);
            border-radius: 50%;
            box-shadow: 
                0 0 40px 8px rgba(66, 133, 244, 0.2),
                inset 0 0 30px rgba(0, 0, 0, 0.9),
                0 0 80px 20px rgba(118, 75, 162, 0.1);
            z-index: 2;
            display: flex;
            align-items: center;
            justify-content: center;
            color: rgba(255, 255, 255, 0.8);
            font-family: 'Orbitron', sans-serif;
            font-weight: 700;
            font-size: 24px;
            text-align: center;
            text-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
            border: 2px solid rgba(102, 126, 234, 0.3);
        }
        .event-horizon {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 220px;
            height: 220px;
            border-radius: 50%;
            border: 2px solid rgba(102, 126, 234, 0.2);
            animation: pulse-ring 4s infinite ease-in-out;
            z-index: 1;
        }
        @keyframes pulse-ring {
            0%, 100% { 
                transform: translate(-50%, -50%) scale(1);
                opacity: 0.5;
            }
            50% { 
                transform: translate(-50%, -50%) scale(1.2);
                opacity: 0.8;
            }
        }
        /* 角色信息 */
        .character-info {
            text-align: center;
            margin-top: 2rem;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .character-name {
            font-family: 'Orbitron', sans-serif;
            font-size: 1.4rem;
            color: #fff;
            text-shadow: 0 0 15px rgba(102, 126, 234, 0.3);
            margin-bottom: 0.8rem;
        }
        .character-description {
            font-size: 1rem;
            color: #aaa;
            max-width: 300px;
            line-height: 1.5;
        }
        /* 粒子系统 */
        .particles-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 0;
        }
        .particle {
            position: absolute;
            pointer-events: none;
            border-radius: 50%;
            z-index: 1;
        }
        /* 聊天界面 - 左侧角色黑洞 + 右侧聊天框 */
        .chat-interface {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(5, 5, 5, 0.95);
            z-index: 1000;
            padding: 2rem;
            overflow: hidden;
        }
        .chat-container {
            display: flex;
            height: 100%;
            gap: 2rem;
        }
        /* 左侧角色黑洞 */
        .left-character-section {
            flex: 0 0 350px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            position: relative;
        }
        .large-character-blackhole {
            position: relative;
            width: 300px;
            height: 300px;
            margin-bottom: 2rem;
        }
        .large-blackhole-core {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 120px;
            height: 120px;
            background: radial-gradient(circle, #0a0a0a 0%, #000000 60%, transparent 100%);
            border-radius: 50%;
            box-shadow: 
                0 0 40px 8px var(--character-color-transparent),
                inset 0 0 30px rgba(0, 0, 0, 0.9),
                0 0 80px 20px var(--character-color-transparent);
            z-index: 2;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--character-color);
            font-family: 'Orbitron', sans-serif;
            font-weight: 700;
            font-size: 24px;
            text-align: center;
            text-shadow: 0 0 15px var(--character-color-transparent);
            border: 2px solid var(--character-color-transparent);
        }
        .large-event-horizon {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 220px;
            height: 220px;
            border-radius: 50%;
            border: 2px solid var(--character-color-transparent);
            animation: pulse-ring 3s infinite ease-in-out;
            z-index: 1;
        }
        .character-title {
            font-family: 'Orbitron', sans-serif;
            font-size: 2rem;
            font-weight: 700;
            color: var(--character-color);
            text-shadow: 0 0 15px var(--character-color-transparent);
            margin-bottom: 0.5rem;
            text-align: center;
        }
        .character-bio {
            color: #aaa;
            font-size: 1rem;
            text-align: center;
            max-width: 300px;
            line-height: 1.5;
        }
        /* 右侧聊天框 */
        .right-chat-section {
            flex: 1;
            display: flex;
            flex-direction: column;
            background: rgba(15, 15, 15, 0.7);
            backdrop-filter: blur(10px);
            border-radius: 16px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
            overflow: hidden;
        }
        .chat-header {
            padding: 1.5rem 2rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .chat-title {
            font-family: 'Orbitron', sans-serif;
            font-size: 1.3rem;
            font-weight: 600;
        }
        .close-chat-btn {
            background: rgba(255, 255, 255, 0.1);
            border: none;
            color: #fff;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            cursor: pointer;
            font-size: 1.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
        }
        .close-chat-btn:hover {
            background: rgba(255, 100, 100, 0.3);
            transform: rotate(90deg);
        }
        .chat-messages-container {
            flex: 1;
            padding: 0 2rem;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 1.2rem;
            padding-top: 2rem;
            padding-bottom: 2rem;
        }
        .message {
            padding: 1rem 1.5rem;
            border-radius: 12px;
            max-width: 80%;
            animation: fadeIn 0.3s ease;
            position: relative;
            line-height: 1.5;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .message.ai {
            background: rgba(50, 50, 50, 0.5);
            align-self: flex-start;
            border-left: 3px solid var(--character-color);
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
        }
        .message.user {
            background: rgba(var(--character-rgb), 0.15);
            align-self: flex-end;
            border-right: 3px solid var(--character-color);
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
        }
        .chat-input-section {
            padding: 1.5rem 2rem;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            gap: 1rem;
        }
        .chat-text-input {
            flex: 1;
            padding: 1rem 1.5rem;
            background: rgba(30, 30, 30, 0.8);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            color: #fff;
            font-size: 1rem;
            outline: none;
            resize: none;
            height: 60px;
            font-family: 'Roboto', sans-serif;
        }
        .chat-text-input:focus {
            border-color: var(--character-color);
            box-shadow: 0 0 0 2px var(--character-color-transparent);
        }
        .send-btn, .voice-btn {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            border: none;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        .send-btn {
            background: linear-gradient(45deg, var(--character-color), var(--character-color-dark));
            color: white;
        }
        .voice-btn {
            background: linear-gradient(45deg, #7bed9f, #2ed573);
            color: white;
        }
        .send-btn:hover, .voice-btn:hover {
            transform: scale(1.1);
            box-shadow: 0 0 20px var(--character-color-transparent);
        }
        .send-icon, .voice-icon {
            width: 24px;
            height: 24px;
            fill: white;
        }
        /* 侧边栏样式 */
        .sidebar {
            position: fixed;
            top: 0;
            left: -300px;
            width: 300px;
            height: 100%;
            background: rgba(15, 15, 15, 0.95);
            backdrop-filter: blur(10px);
            border-right: 1px solid rgba(255, 255, 255, 0.1);
            z-index: 1100;
            transition: left 0.3s ease;
            overflow-y: auto;
            padding: 20px;
            box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
        }
        .sidebar.open {
            left: 0;
        }
        .sidebar-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }
        .sidebar-title {
            font-family: 'Orbitron', sans-serif;
            font-size: 1.2rem;
            font-weight: 600;
        }
        .close-sidebar-btn {
            background: none;
            border: none;
            color: #aaa;
            font-size: 1.5rem;
            cursor: pointer;
            padding: 5px;
        }
        .close-sidebar-btn:hover {
            color: #fff;
        }
        .history-list {
            list-style: none;
        }
        .history-item {
            padding: 12px 15px;
            margin-bottom: 10px;
            background: rgba(30, 30, 30, 0.6);
            border-radius: 8px;
            cursor: pointer;
            transition: background 0.3s ease;
            border: 1px solid rgba(255, 255, 255, 0.05);
        }
        .history-item:hover {
            background: rgba(50, 50, 50, 0.8);
        }
        .history-item.active {
            background: rgba(102, 126, 234, 0.2);
            border: 1px solid rgba(102, 126, 234, 0.3);
        }
        .history-character {
            font-family: 'Orbitron', sans-serif;
            font-size: 0.9rem;
            color: #667eea;
            margin-bottom: 5px;
        }
        .history-preview {
            font-size: 0.85rem;
            color: #aaa;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .no-history {
            color: #777;
            text-align: center;
            font-style: italic;
            padding: 20px 0;
        }
        /* 遮罩层 */
        .overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1050;
        }
        /* 响应式设计 */
        @media (max-width: 1024px) {
            .chat-container {
                flex-direction: column;
            }
            .left-character-section {
                flex: 0 0 auto;
                margin-bottom: 2rem;
            }
            .large-character-blackhole {
                width: 250px;
                height: 250px;
            }
            .large-blackhole-core {
                width: 100px;
                height: 100px;
                font-size: 20px;
            }
            .large-event-horizon {
                width: 180px;
                height: 180px;
            }
        }
        @media (max-width: 768px) {
            .container {
                padding: 1rem;
            }
            h1 {
                font-size: 2rem;
            }
            .search-section {
                padding: 1.5rem;
            }
            .characters-container {
                flex-direction: column;
                gap: 2rem;
            }
            .character-blackhole {
                width: 250px;
                height: 250px;
            }
            .blackhole-core {
                width: 100px;
                height: 100px;
                font-size: 20px;
            }
            .event-horizon {
                width: 180px;
                height: 180px;
            }
            .character-info {
                margin-top: 1.5rem;
            }
            .character-name {
                font-size: 1.2rem;
                margin-bottom: 0.5rem;
            }
            .character-description {
                font-size: 0.9rem;
                max-width: 250px;
            }
            .chat-interface {
                padding: 1rem;
            }
            .chat-header {
                padding: 1rem;
            }
            .chat-messages-container {
                padding: 1rem;
                padding-top: 1.5rem;
                padding-bottom: 1.5rem;
            }
            .chat-input-section {
                padding: 1rem;
            }
            /* 移动端侧边栏适配 */
            .sidebar {
                width: 280px;
            }
        }
    </style>
</head>
<body>
    <!-- 侧边栏 -->
    <div class="sidebar" id="sidebar">
        <div class="sidebar-header">
            <div class="sidebar-title">对话记录</div>
            <button class="close-sidebar-btn" id="close-sidebar-btn">×</button>
        </div>
        <ul class="history-list" id="history-list">
            <li class="no-history">暂无对话记录</li>
        </ul>
    </div>
    <!-- 遮罩层 -->
    <div class="overlay" id="overlay"></div>
    <!-- 个人资料弹窗 -->
    <div class="profile-modal" id="profile-modal">
        <div class="modal-content">
            <div class="modal-header">
                <h2>个人资料</h2>
                <span class="close-btn" id="close-profile-modal">&times;</span>
            </div>
            <div class="modal-body">
                <div class="profile-form">
                    <div class="form-group">
                        <label for="profile-username">用户名</label>
                        <input type="text" id="profile-username" class="form-control" value="用户名称">
                    </div>
                    <div class="form-group">
                        <label for="profile-email">邮箱</label>
                        <input type="email" id="profile-email" class="form-control" value="user@example.com">
                    </div>
                    <div class="form-group">
                        <label for="profile-phone">手机号</label>
                        <input type="tel" id="profile-phone" class="form-control" value="">
                    </div>
                    <div class="form-group">
                        <label for="profile-bio">个人简介</label>
                        <input type="text" id="profile-bio" class="form-control" value="">
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-secondary" id="cancel-profile">取消</button>
                <button class="btn btn-primary" id="save-profile">保存</button>
            </div>
        </div>
    </div>
    <div class="user-menu">
            <button class="user-btn" id="user-btn">
                <span class="user-icon">👤</span>
                <span class="user-name">账号</span>
            </button>
            <div class="user-dropdown" id="user-dropdown">
                <div class="dropdown-header">
                    <span class="user-icon">👤</span>
                    <div>
                        <div class="dropdown-username">用户名称</div>
                        <div class="dropdown-email">user@example.com</div>
                    </div>
                </div>
                <div class="dropdown-divider"></div>
                <a href="#" class="dropdown-item">个人资料</a>
                <a href="#" class="dropdown-item">退出登录</a>
            </div>
        </div>
        <div class="container">
        <header>
            <button class="sidebar-toggle" id="sidebar-toggle">☰</button>
            <h1>AI角色黑洞宇宙</h1>
        </header>
        <p class="subtitle">每个角色都是一个独特的黑洞，吸引着知识的粒子。点击进入他们的引力场，开始一场跨时空的对话。</p>
        <section class="search-section">
            <div class="search-container">
                <input type="text" class="search-input" id="character-search" placeholder="搜索角色，如：哈利波特、苏格拉底、爱因斯坦...">
                <button class="search-btn" id="search-btn">探索宇宙</button>
            </div>
        </section>
        <div class="characters-container" id="characters-container">
            <!-- 角色黑洞将通过JS动态生成 -->
        </div>
    </div>
    <!-- 聊天界面 -->
    <div class="chat-interface" id="chat-interface">
        <div class="chat-container">
            <!-- 左侧角色黑洞 -->
            <div class="left-character-section" id="left-character-section">
                <div class="large-character-blackhole" id="large-character-blackhole">
                    <div class="particles-container" id="large-particles-container"></div>
                    <div class="large-event-horizon" id="large-event-horizon"></div>
                    <div class="large-blackhole-core" id="large-blackhole-core">SW</div>
                </div>
                <h2 class="character-title" id="character-title">孙悟空</h2>
                <p class="character-bio" id="character-bio">中国神话中的齐天大圣，拥有七十二变</p>
            </div>
            <!-- 右侧聊天框 -->
            <div class="right-chat-section">
                <div class="chat-header">
                    <div class="chat-title" id="chat-title">与孙悟空对话</div>
                    <button class="close-chat-btn" id="close-chat-btn">×</button>
                </div>
                <div class="chat-messages-container" id="chat-messages-container">
                    <div class="message ai">
                        你好！我是孙悟空。欢迎来到花果山！有什么想问我的吗？
                    </div>
                </div>
                <div class="chat-input-section">
                    <textarea class="chat-text-input" id="chat-text-input" placeholder="输入你的消息..."></textarea>
                    <button class="voice-btn" id="voice-btn">
                        <svg class="voice-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
                            <path d="M20.01 15.38c-1.23 0-2.42-.2-3.53-.56-.35-.12-.74-.03-1.01.24l-1.57 1.97c-2.83-1.35-5.48-3.9-6.89-6.83l1.95-1.66c.27-.28.35-.67.24-1.02-.37-1.11-.56-2.3-.56-3.53 0-.54-.45-.99-.99-.99H4.19C3.65 3 3 3.24 3 3.99 3 13.28 10.73 21 20.01 21c.71 0 .99-.63.99-1.18v-3.45c0-.54-.45-.99-.99-.99z"/>
                        </svg>
                    </button>
                    <button class="send-btn" id="send-btn">
                        <svg class="send-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
                            <path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/>
                        </svg>
                    </button>
                </div>
            </div>
        </div>
    </div>
    <script>
        // 创建星空背景
        function createStarfield() {
            const body = document.body;
            const starCount = 200;
            for (let i = 0; i < starCount; i++) {
                const star = document.createElement('div');
                star.classList.add('star');
                const size = Math.random() * 2 + 0.5;
                star.style.width = `${size}px`;
                star.style.height = `${size}px`;
                star.style.left = `${Math.random() * 100}%`;
                star.style.top = `${Math.random() * 100}%`;
                const delay = Math.random() * 3;
                star.style.animationDelay = `${delay}s`;
                body.appendChild(star);
            }
        }
        // 角色数据 - 只保留三个角色
        const characters = [
            {
                name: "孙悟空",
                description: "中国神话中的齐天大圣，拥有七十二变",
                initials: "SW",
                color: "#ffd200",
                rgb: "255, 210, 0"
            },
            {
                name: "苏格拉底",
                description: "古希腊哲学家，西方哲学的奠基者之一",
                initials: "SG",
                color: "#764ba2",
                rgb: "118, 75, 162"
            },
            {
                name: "达芬奇",
                description: "文艺复兴时期的博学者，画家、科学家、发明家",
                initials: "DF",
                color: "#4facfe",
                rgb: "79, 172, 254"
            }
        ];
        // 创建角色黑洞
        function createCharacterBlackhole(character, container, x, y) {
            // 创建包装器
            const wrapper = document.createElement('div');
            wrapper.classList.add('character-wrapper');
            // 设置位置 (现在固定，x, y 参数被忽略)
            wrapper.style.position = 'relative'; // 改为 relative 以适应 flex 布局
            // 创建黑洞容器
            const blackhole = document.createElement('div');
            blackhole.classList.add('character-blackhole');
            blackhole.dataset.name = character.name;
            blackhole.dataset.description = character.description;
            blackhole.dataset.initials = character.initials;
            blackhole.dataset.color = character.color;
            // 事件视界
            const eventHorizon = document.createElement('div');
            eventHorizon.classList.add('event-horizon');
            eventHorizon.style.borderColor = `${character.color}40`;
            // 黑洞核心
            const core = document.createElement('div');
            core.classList.add('blackhole-core');
            core.textContent = character.initials;
            core.style.boxShadow = `0 0 40px 8px ${character.color}40, inset 0 0 30px rgba(0, 0, 0, 0.9), 0 0 80px 20px ${character.color}20`;
            core.style.color = `${character.color}`;
            core.style.textShadow = `0 0 15px ${character.color}80`;
            // 粒子容器
            const particlesContainer = document.createElement('div');
            particlesContainer.classList.add('particles-container');
            // 将元素添加到黑洞中
            blackhole.appendChild(particlesContainer);
            blackhole.appendChild(eventHorizon);
            blackhole.appendChild(core);
            // 创建粒子
            createParticles(particlesContainer, character.color);
            // 创建包含名称和简介的容器
            const infoContainer = document.createElement('div');
            infoContainer.classList.add('character-info');
            // 角色名称
            const nameElement = document.createElement('div');
            nameElement.classList.add('character-name');
            nameElement.textContent = character.name;
            // 角色描述
            const descElement = document.createElement('div');
            descElement.classList.add('character-description');
            descElement.textContent = character.description;
            // 将名称和简介添加到信息容器
            infoContainer.appendChild(nameElement);
            infoContainer.appendChild(descElement);
            // 点击事件绑定到整个包装器
            wrapper.addEventListener('click', function() {
                openChatInterface(character);
            });
            // 将黑洞和信息容器添加到包装器
            wrapper.appendChild(blackhole);
            wrapper.appendChild(infoContainer);
            // 将包装器添加到主容器
            container.appendChild(wrapper);
        }
        // 创建粒子
        function createParticles(container, color) {
            const particleCount = 15;
            for (let i = 0; i < particleCount; i++) {
                const particle = document.createElement('div');
                particle.classList.add('particle');
                // 粒子大小
                const size = Math.random() * 3 + 1;
                particle.style.width = `${size}px`;
                particle.style.height = `${size}px`;
                // 设置粒子颜色
                const opacity = Math.random() * 0.5 + 0.3;
                particle.style.backgroundColor = `${color}${Math.floor(opacity * 100).toString(16).padStart(2, '0')}`;
                // 粒子轨道半径
                const radius = Math.random() * 75 + 60; // 增大半径以适应放大后的黑洞
                // 初始角度
                const angle = Math.random() * Math.PI * 2;
                // 设置粒子位置
                const x = Math.cos(angle) * radius;
                const y = Math.sin(angle) * radius;
                particle.style.transform = `translate(${x}px, ${y}px)`;
                // 动画持续时间
                const duration = Math.random() * 20 + 10;
                // 创建动画
                particle.style.animation = `
                    rotate ${duration}s linear infinite,
                    pulse ${Math.random() * 2 + 1}s ease-in-out infinite alternate
                `;
                // 添加关键帧样式
                const styleId = `particle-animation-${Date.now()}-${i}`;
                if (!document.getElementById(styleId)) {
                    const style = document.createElement('style');
                    style.id = styleId;
                    style.textContent = `
                        @keyframes rotate {
                            from { transform: translate(${x}px, ${y}px) rotate(0deg); }
                            to { transform: translate(${x}px, ${y}px) rotate(360deg); }
                        }
                        @keyframes pulse {
                            from { opacity: 0.3; }
                            to { opacity: 0.8; }
                        }
                    `;
                    document.head.appendChild(style);
                }
                container.appendChild(particle);
            }
        }
        // 对话历史记录
        let chatHistory = [];
        // 保存对话到历史记录
        function saveToHistory(character, messages) {
            // 获取最后一条用户消息作为预览
            let preview = "新对话";
            for (let i = messages.length - 1; i >= 0; i--) {
                if (messages[i].classList.contains('user')) {
                    preview = messages[i].textContent;
                    break;
                }
            }
            // 如果预览太长则截断
            if (preview.length > 30) {
                preview = preview.substring(0, 30) + "...";
            }
            // 检查是否已存在该角色的记录
            const existingIndex = chatHistory.findIndex(item => item.character.name === character.name);
            if (existingIndex !== -1) {
                // 更新现有记录
                chatHistory[existingIndex] = {
                    character: character,
                    messages: Array.from(messages),
                    preview: preview,
                    timestamp: new Date()
                };
            } else {
                // 添加新记录
                chatHistory.unshift({
                    character: character,
                    messages: Array.from(messages),
                    preview: preview,
                    timestamp: new Date()
                });
            }
            // 保持最多10条记录
            if (chatHistory.length > 10) {
                chatHistory.pop();
            }
            // 更新侧边栏显示
            updateHistoryList();
        }
        // 更新历史记录列表
        function updateHistoryList() {
            const historyList = document.getElementById('history-list');
            historyList.innerHTML = '';
            if (chatHistory.length === 0) {
                const noHistory = document.createElement('li');
                noHistory.className = 'no-history';
                noHistory.textContent = '暂无对话记录';
                historyList.appendChild(noHistory);
                return;
            }
            chatHistory.forEach((item, index) => {
                const li = document.createElement('li');
                li.className = 'history-item';
                li.innerHTML = `
                    <div class="history-character">${item.character.name}</div>
                    <div class="history-preview">${item.preview}</div>
                `;
                li.addEventListener('click', () => {
                    // 重新打开聊天界面并加载历史记录
                    openChatInterface(item.character);
                    // 延迟加载消息以确保DOM已更新
                    setTimeout(() => {
                        const container = document.getElementById('chat-messages-container');
                        container.innerHTML = '';
                        item.messages.forEach(msg => {
                            // 克隆消息元素
                            const clonedMsg = msg.cloneNode(true);
                            container.appendChild(clonedMsg);
                        });
                        // 滚动到底部
                        container.scrollTop = container.scrollHeight;
                    }, 100);
                    // 关闭侧边栏
                    closeSidebar();
                });
                historyList.appendChild(li);
            });
        }
        // 打开聊天界面
        function openChatInterface(character) {
            const chatInterface = document.getElementById('chat-interface');
            const leftCharacterSection = document.getElementById('left-character-section');
            const largeBlackholeCore = document.getElementById('large-blackhole-core');
            const largeEventHorizon = document.getElementById('large-event-horizon');
            const largeParticlesContainer = document.getElementById('large-particles-container');
            const characterTitle = document.getElementById('character-title');
            const characterBio = document.getElementById('character-bio');
            const chatTitle = document.getElementById('chat-title');
            const chatMessagesContainer = document.getElementById('chat-messages-container');
            // 设置CSS变量
            document.documentElement.style.setProperty('--character-color', character.color);
            document.documentElement.style.setProperty('--character-color-transparent', `${character.color}60`);
            document.documentElement.style.setProperty('--character-color-dark', shadeColor(character.color, -30));
            document.documentElement.style.setProperty('--character-rgb', character.rgb);
            // 更新黑洞内容
            largeBlackholeCore.textContent = character.initials;
            largeEventHorizon.style.borderColor = `${character.color}80`;
            largeBlackholeCore.style.color = character.color;
            largeBlackholeCore.style.boxShadow = `0 0 40px 8px ${character.color}40, inset 0 0 30px rgba(0, 0, 0, 0.9), 0 0 80px 20px ${character.color}20`;
            largeBlackholeCore.style.textShadow = `0 0 15px ${character.color}80`;
            largeBlackholeCore.style.border = `2px solid ${character.color}60`;
            // 更新文字内容
            characterTitle.textContent = character.name;
            characterBio.textContent = character.description;
            chatTitle.textContent = `与${character.name}对话`;
            // 清空并重新创建粒子
            largeParticlesContainer.innerHTML = '';
            createParticles(largeParticlesContainer, character.color);
            // 清空聊天记录并添加欢迎消息
            chatMessagesContainer.innerHTML = '';
            const welcomeMessages = {
                '孙悟空': '俺老孙来也！有什么妖怪需要我帮你打吗？或者你想听西游故事？',
                '苏格拉底': '我是苏格拉底。真正的智慧在于承认自己的无知。你想探讨什么哲学问题？',
                '达芬奇': '我是列奥纳多·达·芬奇。艺术与科学本为一体。你想了解什么？',
            };
            const welcomeMessage = document.createElement('div');
            welcomeMessage.classList.add('message', 'ai');
            welcomeMessage.textContent = welcomeMessages[character.name] || `你好！我是${character.name}。很高兴和你对话！`;
            chatMessagesContainer.appendChild(welcomeMessage);
            // 显示聊天界面
            chatInterface.style.display = 'block';
            // 禁止背景滚动
            document.body.style.overflow = 'hidden';
        }
        // 关闭聊天界面
        function closeChatInterface() {
            const chatInterface = document.getElementById('chat-interface');
            const messages = document.querySelectorAll('#chat-messages-container .message');
            const characterTitle = document.getElementById('character-title').textContent;
            // 找到当前角色
            const currentCharacter = characters.find(char => char.name === characterTitle);
            // 保存对话历史（只有当有消息时才保存）
            if (messages.length > 1 && currentCharacter) { // >1 because welcome message is always there
                saveToHistory(currentCharacter, messages);
            }
            chatInterface.style.display = 'none';
            // 恢复背景滚动
            document.body.style.overflow = 'auto';
        }
        // 辅助函数：调整颜色亮度
        function shadeColor(color, percent) {
            let R = parseInt(color.substring(1, 3), 16);
            let G = parseInt(color.substring(3, 5), 16);
            let B = parseInt(color.substring(5, 7), 16);
            R = parseInt(R * (100 + percent) / 100);
            G = parseInt(G * (100 + percent) / 100);
            B = parseInt(B * (100 + percent) / 100);
            R = (R < 255) ? R : 255;
            G = (G < 255) ? G : 255;
            B = (B < 255) ? B : 255;
            const RR = ((R.toString(16).length === 1) ? "0" + R.toString(16) : R.toString(16));
            const GG = ((G.toString(16).length === 1) ? "0" + G.toString(16) : G.toString(16));
            const BB = ((B.toString(16).length === 1) ? "0" + B.toString(16) : B.toString(16));
            return "#" + RR + GG + BB;
        }
        // 搜索功能
        function searchCharacters() {
            const searchTerm = document.getElementById('character-search').value.toLowerCase().trim();
            const container = document.getElementById('characters-container');
            container.innerHTML = '';
            if (searchTerm) {
                // 搜索模式：只显示匹配的角色
                const filteredCharacters = characters.filter(char => 
                    char.name.toLowerCase().includes(searchTerm) || 
                    char.description.toLowerCase().includes(searchTerm)
                );
                if (filteredCharacters.length === 0) {
                    // 显示"未找到"消息
                    const notFound = document.createElement('div');
                    notFound.style.textAlign = 'center';
                    notFound.style.padding = '2rem';
                    notFound.style.color = '#aaa';
                    notFound.innerHTML = `<h3>未找到 "${searchTerm}" 相关角色</h3>`;
                    container.appendChild(notFound);
                } else {
                    filteredCharacters.forEach(character => {
                        createCharacterBlackhole(character, container, 0, 0); // x, y 被忽略
                    });
                }
            } else {
                // 显示所有角色
                characters.forEach(character => {
                    createCharacterBlackhole(character, container, 0, 0); // x, y 被忽略
                });
            }
        }
        // 初始化
        function initialize() {
            const container = document.getElementById('characters-container');
            container.innerHTML = '';
            // 创建所有角色
            characters.forEach(character => {
                createCharacterBlackhole(character, container, 0, 0); // x, y 被忽略
            });
        }
        // 侧边栏功能
        function openSidebar() {
            document.getElementById('sidebar').classList.add('open');
            document.getElementById('overlay').style.display = 'block';
            document.body.style.overflow = 'hidden';
        }
        function closeSidebar() {
            document.getElementById('sidebar').classList.remove('open');
            document.getElementById('overlay').style.display = 'none';
            document.body.style.overflow = 'auto';
        }
        // 初始化
        document.addEventListener('DOMContentLoaded', function() {
            createStarfield();
            // 初始化
            initialize();
            // 搜索按钮事件
            document.getElementById('search-btn').addEventListener('click', searchCharacters);
            // 搜索输入框回车事件
            document.getElementById('character-search').addEventListener('keypress', function(e) {
                if (e.key === 'Enter') {
                    searchCharacters();
                }
            });
            // 关闭聊天界面按钮
            document.getElementById('close-chat-btn').addEventListener('click', closeChatInterface);
            // 发送消息功能
            const chatTextInput = document.getElementById('chat-text-input');
            const sendBtn = document.getElementById('send-btn');
            const voiceBtn = document.getElementById('voice-btn');
            const chatMessagesContainer = document.getElementById('chat-messages-container');
            function sendMessage() {
                const message = chatTextInput.value.trim();
                if (!message) return;
                // 添加用户消息
                const userMessage = document.createElement('div');
                userMessage.classList.add('message', 'user');
                userMessage.textContent = message;
                chatMessagesContainer.appendChild(userMessage);
                // 清空输入框
                chatTextInput.value = '';
                // 滚动到底部
                chatMessagesContainer.scrollTop = chatMessagesContainer.scrollHeight;
                // 模拟AI回复
                setTimeout(() => {
                    const aiMessage = document.createElement('div');
                    aiMessage.classList.add('message', 'ai');
                    const currentCharacter = document.getElementById('character-title').textContent;
                    let reply = '';
                    switch(currentCharacter) {
                        case '孙悟空':
                            reply = '嘿嘿，这个问题难不倒俺老孙！一个筋斗云就能解决！不过说真的，你得先有金箍棒般的决心才能克服困难！';
                            break;
                        case '苏格拉底':
                            reply = '你提出了一个值得深思的问题。但让我先问你：你认为这个问题的本质是什么？通过提问，我们往往能更接近真理。';
                            break;
                        case '达芬奇':
                            reply = '啊，多么美妙的问题！在我的笔记本中，我曾画过类似的草图。艺术与科学的结合总能产生惊人的洞见。';
                            break;
                        default:
                            reply = '这是个很有趣的问题！作为AI角色，我还在学习中，但我很乐意和你一起探讨这个话题。';
                    }
                    aiMessage.textContent = reply;
                    chatMessagesContainer.appendChild(aiMessage);
                    // 滚动到底部
                    chatMessagesContainer.scrollTop = chatMessagesContainer.scrollHeight;
                }, 1000);
            }
            // 发送按钮点击事件
            sendBtn.addEventListener('click', sendMessage);
            // 文本输入框回车事件
            chatTextInput.addEventListener('keypress', function(e) {
                if (e.key === 'Enter' && !e.shiftKey) {
                    e.preventDefault();
                    sendMessage();
                }
            });
            // 打电话按钮功能
            let isCalling = false;
            let callTimer;
            voiceBtn.addEventListener('click', function() {
                if (!isCalling) {
                    // 开始打电话
                    isCalling = true;
                    // 获取当前聊天角色的名称
                    const currentCharacter = document.getElementById('character-title').textContent;
                    let phoneNumber = '';
                    // 根据不同角色设置不同的电话号码
                    switch(currentCharacter) {
                        case '孙悟空':
                            phoneNumber = '86-10-1234-5678'; // 中国号码格式
                            break;
                        case '苏格拉底':
                            phoneNumber = '30-21-0123-4567'; // 希腊号码格式
                            break;
                        case '达芬奇':
                            phoneNumber = '39-02-1234-5678'; // 意大利号码格式
                            break;
                        default:
                            phoneNumber = '86-10-1234-5678'; // 默认中国号码格式
                    }
                    // 直接改变按钮样式为红色挂断按钮
                    this.style.background = 'linear-gradient(45deg, #ff4757, #ff3742)';
                    this.innerHTML = '<svg class="voice-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>';
                    // 5秒后自动结束通话
                    callTimer = setTimeout(() => {
                        endCall();
                    }, 5000);
                } else {
                    // 结束通话
                    endCall();
                }
            });
            // 结束通话函数
            function endCall() {
                isCalling = false;
                clearTimeout(callTimer);
                // 恢复按钮原始样式为淡绿色
                voiceBtn.style.background = 'linear-gradient(45deg, #7bed9f, #2ed573)';
                voiceBtn.innerHTML = '<svg class="voice-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.01 15.38c-1.23 0-2.42-.2-3.53-.56-.35-.12-.74-.03-1.01.24l-1.57 1.97c-2.83-1.35-5.48-3.9-6.89-6.83l1.95-1.66c.27-.28.35-.67.24-1.02-.37-1.11-.56-2.3-.56-3.53 0-.54-.45-.99-.99-.99H4.19C3.65 3 3 3.24 3 3.99 3 13.28 10.73 21 20.01 21c.71 0 .99-.63.99-1.18v-3.45c0-.54-.45-.99-.99-.99z"/></svg>';
                // 通话结束，无提示
            }
            // 点击遮罩层关闭聊天界面
            document.getElementById('chat-interface').addEventListener('click', function(e) {
                if (e.target === this) {
                    closeChatInterface();
                }
            });
            // 侧边栏功能
            document.getElementById('sidebar-toggle').addEventListener('click', openSidebar);
            document.getElementById('close-sidebar-btn').addEventListener('click', closeSidebar);
            document.getElementById('overlay').addEventListener('click', closeSidebar);
            // 初始化历史记录列表
            updateHistoryList();
            // 个人按钮功能
            const userBtn = document.getElementById('user-btn');
            const userDropdown = document.getElementById('user-dropdown');
            // 点击个人按钮显示/隐藏下拉菜单
            userBtn.addEventListener('click', function(e) {
                e.stopPropagation();
                userDropdown.classList.toggle('show');
            });
            // 点击页面其他地方隐藏下拉菜单
            document.addEventListener('click', function(e) {
                if (!userBtn.contains(e.target) && !userDropdown.contains(e.target)) {
                    userDropdown.classList.remove('show');
                }
            });
            // 下拉菜单项点击事件
            const dropdownItems = document.querySelectorAll('.dropdown-item');
            dropdownItems.forEach(item => {
                item.addEventListener('click', function(e) {
                    e.preventDefault();
                    const text = this.textContent;
                    if (text === '退出登录') {
                        // 模拟退出登录
                        alert('您已退出登录');
                    } else if (text === '个人资料') {
                        // 显示个人资料弹窗
                        document.getElementById('profile-modal').style.display = 'flex';
                    } else {
                        alert(`您点击了：${text}`);
                    }
                    userDropdown.classList.remove('show');
                });
            });
            // 个人资料弹窗功能
            const profileModal = document.getElementById('profile-modal');
            const closeProfileModal = document.getElementById('close-profile-modal');
            const cancelProfile = document.getElementById('cancel-profile');
            const saveProfile = document.getElementById('save-profile');
            // 关闭弹窗
            function closeProfileModalFunc() {
                profileModal.style.display = 'none';
            }
            // 关闭弹窗事件
            closeProfileModal.addEventListener('click', closeProfileModalFunc);
            cancelProfile.addEventListener('click', closeProfileModalFunc);
            // 点击遮罩层关闭弹窗
            profileModal.addEventListener('click', function(e) {
                if (e.target === profileModal) {
                    closeProfileModalFunc();
                }
            });
            // 保存个人资料
            saveProfile.addEventListener('click', function() {
                // 获取表单数据
                const username = document.getElementById('profile-username').value;
                const email = document.getElementById('profile-email').value;
                const phone = document.getElementById('profile-phone').value;
                const bio = document.getElementById('profile-bio').value;
                // 这里可以添加保存到服务器的逻辑
                // 模拟保存成功
                alert('个人资料已保存');
                // 更新下拉菜单中的用户信息
                document.querySelector('.dropdown-username').textContent = username;
                document.querySelector('.dropdown-email').textContent = email;
                // 关闭弹窗
                closeProfileModalFunc();
            });
        });
    </script>
</body>
</html>